package com.xiaoxi.bms.common.exception;

import com.xiaoxi.bms.common.constant.enumeration.statuscode.ParentEnum;
import org.springframework.security.core.AuthenticationException;

import java.util.Map;

/**
 * @ClassName BMSSecurityException
 * @Description 自定义 SpringSecurity  处理异常类
 * @Author xiaoxi
 * @Date 2022/4/24 14:44
 * @Version 1.0
 */
public class BMSSecurityException extends AuthenticationException {

    private String code;
    private String message;

    public BMSSecurityException(String code, String message) {

        super(message);
        this.code = code;
        this.message = message;

    }

    public BMSSecurityException(ParentEnum parentEnum) {
        super(parentEnum.format().get("message"));
        Map<String, String> enumData = parentEnum.format();
        this.code = enumData.get("code");
        this.message = enumData.get("message");

    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
